package Comprehensive_01;

import java.util.Scanner;

public class PlaneTicket {
    public static void main(String[] args) {
        /* 机票价格按照淡季旺季、头等舱和经济仓收费，输入机票价格、月份和头等舱或经济舱。
    按照如下规则计算票价：旺季（5 ~ 10月）头等舱9折，经济舱8.5折，淡季（11月到来年的4月）头等舱7折，经济舱6.5折
     */

        // 键盘录入机票价格、月份、头等舱或经济舱
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入机票价格：");
        int ticket = scanner.nextInt();
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        System.out.println("请输入机舱：0 头等舱 1 经济舱：");
        int seat = scanner.nextInt();

        // 判断季节
        // idea提取方法快捷键，选中要提取的方法Ctrl + Alt + M
        discountTicket(ticket, month, seat);

    }

    private static void discountTicket(int ticket, int month, int seat) {
        if (month >= 5 && month <=10){
            //旺季（5 ~ 10月）头等舱9折，经济舱8.5折
            ticket = getTicket(seat, ticket, 0.9, 0.85);
        } else if ((month > 0 && month < 5) || (month > 10 && month < 13)) {
            // 淡季（11月到来年的4月）头等舱7折，经济舱6.5折
            ticket = getTicket(seat, ticket, 0.7, 0.65);
        }else {
            System.out.println("录入的月份不合理");
        }
        System.out.println("机票折后的价格为：" + ticket);
    }

    private static int getTicket(int seat, int ticket, double v1, double v2) {
        if (seat == 0){
            ticket *= v1;
        } else if (seat == 1) {
            ticket *= v2;
        }else{
            System.out.println("不存在此舱位");
        }
        return ticket;
    }
}
